<include file="Public:header" />
<include file="Public:leftside" />
<style>
.caltime .btn{color: #fff;padding: 1px 7px;}
</style>
<div class="main-content">
	<div class="breadcrumbs breadcrumbs-fixed" id="breadcrumbs">
		<ul class="breadcrumb">
			<li> <i class="icon-home home-icon"></i> <a href="/">首页</a> </li>
			<li><a href="javascript:;">广告管理</a></li>
	
		</ul>
	</div>
	<div class="page-content">

    <section class="panel-default m-b-sm">
        <div class="alert alert-info">
            <p>
              <i class="fa fa-hand-o-right m-r-xs"></i><strong>操作提示</strong>
            </p>
            <p class="alert-p m-l-xl"><i class="fa fa-caret-right m-r-xs"></i>该页面可编辑幻灯片广告。</p>
            
        </div>
     </section>
    <div class="listContent">

    	<div class="wrap js-check-wrap">
       <form class="form form-horizontal" role="form" action="{:U('Shop/postSliderAD',array('id'=>$_GET['id']))}" method="post" novalidate="novalidate">
      <div class="tabbable">
            <div class="tab-content">
             <input type="hidden" name="postType" value="edit">
             <input type="hidden" name="adKey" value="{$adKey}">
            <fieldset>
              <div class="form-group">
                <label class="col-sm-2 control-label">广告标题</label>
                <div class="controls">
                  <input type="text" name="ad_title" value="" required="" aria-required="true"><span class="form-required"> *</span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">次级广告标题</label>
                <div class="controls">
                  <input type="text" name="second_title" value="">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">广告副标题</label>
                <div class="controls">
                  <input type="text" name="sub_title" value="">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">跳转链接</label>
                <div class="controls">
                  <input type="text" name="ad_link" value="" style="width:400px" required="" aria-required="true"><span class="form-required"> *</span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">广告图片</label>
                <div class="controls">
                  <div id="uploader" style="width:200px;overflow:hidden">
                      <div id="fileList" class="uploader-list">
                      <div id="WU_FILE_0" class="file-item thumbnail upload-state-done"><img class="img-responsive" src=""></div>
                      <input type="hidden" name="UpFilePathInfo" value="">
                      </div>
                      <div id="cfilePicker">选择图片</div>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">广告时间段</label>
                <div class="controls">
                <input type="text" name="start_time" class="js-datetime date" value="" style="width: 150px;" autocomplete="off">-
                <input type="text" class="js-datetime date" name="end_time" value="" style="width: 150px;" autocomplete="off">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="controls">
                  <select name="ad_status">
                    <option value="1">投放</option>
                    <option value="0">禁用</option>
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="controls">
                  <input type="text" name="listorder" value="0" required="" aria-required="true"><span class="form-required"> *</span>
                </div>
              </div>
             <?php if($ad_type==2){?>
             <div class="form-group">
                <label class="col-sm-2 control-label">原价</label>
                <div class="controls">
                   <input type="text" class="oprice" name="oprice" >
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">售价</label>
                <div class="controls">
                   <input type="text" class="price" name="price" >
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">绑定商品ID</label>
                <div class="controls">
                   <input type="text" class="shop_id" value="" >
                    <button class="btn btn-info btn-shop"  type="button">绑定商品</button>
                </div>
              </div>
              <?php }?>
              <?php if($ad_type==4){?>
               <div class="form-group">
                <label class="col-sm-2 control-label">绑定店铺ID</label>
                <div class="controls">
                   <input type="text" class="store_id" value="" >
                    <button class="btn btn-info btn-store"  type="button">绑定店铺</button>
                </div>
              </div>
                <?php }?>
              <?php if($ad_type==3){?>
               <div class="form-group">
                <label class="col-sm-2 control-label">绑定品牌ID</label>
                <div class="controls">
                   <input type="text" class="brand_id" value="" >
                    <button class="btn btn-info btn-brand"  type="button">绑定品牌</button>
                </div>
              </div>
                <?php }?>
              <div class="form-actions" style="padding-left: 17%;">
               <button class="btn btn-info formSubmit" id="form" type="button"><i class="icon-ok bigger-110"></i>提交</button>
                <a class="btn btn-default" href="{:U('shop/manageSliderAD',array('id'=>$_GET['id'],'ad_name'=>$_GET['ad_name']))}">返回</a>
              </div>
            </fieldset>
              </div>

            </div>
        </div>
        
    </form>
    
      
    
  
      </div>
    </div>
   </div>
</div>

<script>
//全局变量
    var GV = {
         DIMAUB: "/",
        JS_ROOT: "NewAdmin/js/",
        TOKEN: ""
    };
</script>
<script type="text/javascript" src="/NewAdmin/js/webuploader/webuploader.js"></script>
<script type="text/javascript" src="/NewAdmin/js/webuploader/getting-started.js"></script>
<link rel="stylesheet" href="/NewAdmin/css/webuploader.css" />
<script src="/NewAdmin/js/wind.js"></script>
<link href="/NewAdmin/js/artDialog/skins/default.css" rel="stylesheet" />
<script src="/NewAdmin/js/zhlmy.js"></script>
<script type="text/javascript">
var BASE_URL = '/NewAdmin/js/webuploader/';
var UPLOAD_SERVER='{:U("User/uploadify_wb")}';
var adData='{$adData.ad_data}';
var adKey='{$adKey}'
$(function() {
    if(adData!==''){
      adData=$.parseJSON(adData);
      $(':input[name="ad_title"]').val(adData.AdItem[adKey].ad_title);
      $(':input[name="second_title"]').val(adData.AdItem[adKey].second_title);
      $(':input[name="sub_title"]').val(adData.AdItem[adKey].sub_title);
      $(':input[name="ad_link"]').val(adData.AdItem[adKey].ad_link);
      $(':input[name="ad_bgcolor"]').val(adData.AdItem[adKey].ad_bgcolor);
      $(':input[name="start_time"]').val(adData.AdItem[adKey].start_time);
      $(':input[name="end_time"]').val(adData.AdItem[adKey].end_time);    
      $('select[name="ad_status"]').val(adData.AdItem[adKey].ad_status);
      $(':input[name="listorder"]').val(adData.AdItem[adKey].listorder);
      $(':input[name="UpFilePathInfo"]').val(adData.AdItem[adKey].UpFilePathInfo);
      $(':input[name="oprice"]').val(adData.AdItem[adKey].oprice);
      $(':input[name="price"]').val(adData.AdItem[adKey].price);
      $('#uploader img').attr('src',adData.AdItem[adKey].UpFilePathInfo)
    }

   //日期+时间选择器
    var dateTimeInput = $("input.js-datetime");
    if (dateTimeInput.length) {
        Wind.use('datePicker', function () {
            dateTimeInput.datePicker({
                time: true
            });
        });
    }

  $("#uploader").setUploader(null,{uploadImgType:'normal',thumb:{height:102}});
  $('.btn-shop').click(function(){
    var id=$('.shop_id').val();
    $.ajax({
         type: "post",
         url: "{:U('Shop/get_shop')}",
         data: {id:id},
         dataType: "json",
         success: function(data){
            if(data){
               if(data.image){
                 $(':input[name="UpFilePathInfo"]').val(data.image);
                 $('#uploader img').attr('src',data.image)
               }
              $(':input[name="ad_title"]').val(data.title);
              $(':input[name="ad_link"]').val(data.url);
              $(':input[name="oprice"]').val(data.oprice);
              $(':input[name="price"]').val(data.price);
            }else{
              layer.msg('商品不存在！');
           }         
        }
    });
  })
  $('.btn-store').click(function(){
    var id=$('.store_id').val();
     $.ajax({
         type: "post",
         url: "{:U('Shop/get_store')}",
         data: {id:id},
         dataType: "json",
         success: function(data){
           if(data){
              if(data.image){
                 $(':input[name="UpFilePathInfo"]').val(data.image);
                 $('#uploader img').attr('src',data.image)
              }
              $(':input[name="ad_title"]').val(data.title);
               $(':input[name="ad_link"]').val(data.url);
           }else{
              layer.msg('店铺不存在！');
           }     
        }
    });
  })
  $('.btn-brand').click(function(){
    var id=$('.brand_id').val();
     $.ajax({
         type: "post",
         url: "{:U('Shop/get_brand')}",
         data: {id:id},
         dataType: "json",
         success: function(data){
            if(data){
              if(data.image){
                 $(':input[name="UpFilePathInfo"]').val(data.image);
                 $('#uploader img').attr('src',data.image)
              }
              $(':input[name="ad_title"]').val(data.name);
                $(':input[name="ad_link"]').val(data.url);
           }else{
              layer.msg('品牌不存在！');
           }         
        }
    });
  })

});
</script>
<include file="Public:footer" />
